Skip to content

[MCP SDK] Example update to use proper logging #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ineersa
Copy link

@ineersa ineersa commented Aug 19, 2025

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #306
License MIT

Added monolog as dev dependency.
Swapped ConsoleLogger to Monolog -> STDERR with JsonFormatter.
Added commentary with explanation

@ineersa ineersa marked this pull request as ready for review August 19, 2025 22:38
@carsonbot carsonbot added Bug Something isn't working MCP SDK Issues & PRs about the MCP SDK Status: Needs Review labels Aug 19, 2025
@OskarStark OskarStark requested a review from Copilot August 21, 2025 19:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the MCP SDK example to use proper Monolog logging instead of Symfony's ConsoleLogger. The change addresses issue #306 by implementing structured JSON logging to STDERR as required by the MCP protocol.

Key changes:

  • Replace Symfony ConsoleLogger with Monolog logger configured for JSON output to STDERR
  • Add Monolog as a development dependency
  • Include detailed comments explaining the logging requirements and limitations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/mcp-sdk/examples/cli/index.php Replace ConsoleLogger with Monolog using StreamHandler and JsonFormatter for STDERR output
src/mcp-sdk/composer.json Add monolog/monolog as development dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$logger = new SymfonyConsole\Logger\ConsoleLogger($output);

// Setup *Monolog* logger, logger must output JSON to stream to STDERR
// **WARNING** this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment uses Markdown formatting (Monolog and WARNING) which is not appropriate for PHP code comments. Consider using plain text formatting for better readability in the source code.

Suggested change
// **WARNING** this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client
// Setup Monolog logger, logger must output JSON to stream to STDERR
// WARNING: this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working MCP SDK Issues & PRs about the MCP SDK Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MCP SDK] Logging
2 participants